Skip to content

Yul: dump source/target stacks when findStackTooDeep aborts#16705

Closed
msooseth wants to merge 1 commit into
argotorg:developfrom
msooseth:dump-shuffle-failure
Closed

Yul: dump source/target stacks when findStackTooDeep aborts#16705
msooseth wants to merge 1 commit into
argotorg:developfrom
msooseth:dump-shuffle-failure

Conversation

@msooseth

@msooseth msooseth commented May 12, 2026

Copy link
Copy Markdown
Contributor

Add an opt-in debug dump for the case described in #16704: when findStackTooDeep propagates a YulAssertion from createStackLayout (e.g. "Could not create stack layout after 1000 iterations"), the source and target stacks at that point are otherwise opaque to anyone debugging from a user-supplied .sol reproducer.

When the environment variable YUL_DEBUG_DUMP_SHUFFLE_FAILURE is set to a non-empty value, the source and target stacks (rendered via the existing stackToString(Stack, Dialect) helper) are printed to stderr in the StackShufflingTest .stack format (see test/libyul/yulStackShuffling/*.stack), so the failing input can be dropped into the test suite verbatim. Example:

// findStackTooDeep aborted (source.size=1, target.size=1237)
[ RET ]
[ RET RET[fun_double_27] RET[fun_double_27] ... ]
// ====
// maximumStackDepth: 16

Mechanically:

  • findStackTooDeep gains a Dialect const& parameter (needed by stackToString for resolving function names in RET[...] / TMP[...] slots). All four call sites already have m_evmDialect available and pass it through.
  • The ::createStackLayout invocation is wrapped in a try / catch (YulAssertion const&) that does the conditional stderr print and then throw;s — so when the env var is unset, behavior is byte-identical to before.

No Changelog entry: this is a developer-only debug aid and doesn't change any user-visible behavior.

Refs #16704.

Add an opt-in debug dump for the case described in
argotorg#16704: when `findStackTooDeep` propagates a
`YulAssertion` from `createStackLayout` (e.g. "Could not create stack
layout after 1000 iterations"), the source and target stacks at that
point are otherwise opaque to anyone debugging from a user-supplied
.sol reproducer.

When the environment variable `YUL_DEBUG_DUMP_SHUFFLE_FAILURE` is set
to a non-empty value, the source and target stacks (rendered via the
existing `stackToString(Stack, Dialect)` helper) are printed to stderr
in the StackShufflingTest `.stack` format (see
test/libyul/yulStackShuffling/*.stack), so the failing input can be
dropped into the test suite verbatim. Example:

    // findStackTooDeep aborted (source.size=1, target.size=1237)
    [ RET ]
    [ RET RET[fun_double_27] RET[fun_double_27] ... ]
    // ====
    // maximumStackDepth: 16

Mechanically:

* `findStackTooDeep` gains a `Dialect const&` parameter (needed by
  `stackToString` for resolving function names in `RET[...]` /
  `TMP[...]` slots). All four call sites already have `m_evmDialect`
  available and pass it through.
* The `::createStackLayout` invocation is wrapped in a `try` /
  `catch (YulAssertion const&)` that does the conditional stderr
  print and then `throw;`s -- so when the env var is unset, behavior
  is byte-identical to before.

No Changelog entry: this is a developer-only debug aid and doesn't
change any user-visible behavior.
@msooseth msooseth force-pushed the dump-shuffle-failure branch from d4b4c10 to 11214b1 Compare May 12, 2026 09:50
@github-actions

Copy link
Copy Markdown

This pull request is stale because it has been open for 14 days with no activity.
It will be closed in 7 days unless the stale label is removed.

@github-actions github-actions Bot added the stale The issue/PR was marked as stale because it has been open for too long. label May 26, 2026
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

This pull request was closed due to a lack of activity for 7 days after it was stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closed-due-inactivity stale The issue/PR was marked as stale because it has been open for too long.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant